#include <iostream>
#include <string>
using namespace std;
void LPS(const string& pattern, int* lps)
{
    int n = pattern.length();
    int len = 0;
    lps[0] = 0;
    int i = 1;
    while (i < n) {
        if (pattern[i] == pattern[len])
        {
            len++;
            lps[i] = len;
            i++;
        }
        else
        {
            if (len != 0)
            {
                len = lps[len - 1];
            }
            else
            {
                lps[i] = 0;
                i++;
            }
        }
    }
}
 
int KMP(const string& text, const string& pattern)
{
    int n = text.length();
    int m = pattern.length();
    int lps[m] = {0};
    LPS(pattern, lps);
    int count = 0;
    int i = 0, j = 0;
    while (i < n)
    {
        if (text[i] == pattern[j])
        {
            i++;
            j++;
            if (j == m) {
                count++;
                j = lps[j - 1];
            }
        }
        else
        {
            if (j > 0)
            {
                j = lps[j - 1];
            } 
            else
            {
                i++;
            }
        }
    }
    return count;
}
 
int main()
{
    string text, pattern;
    cin >> text >> pattern;
    int result = KMP(text, pattern);
    cout << result << endl;
    return 0;
}